package com.homelock.common.enums;

import com.homelock.common.enums.sms.SmsSendTypeEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 开门记录 报警记录 触发类型
 *
 * @author chenmf@163.com
 * @date 2020年07月15日03:57:48
 */
@Getter
@AllArgsConstructor
public enum ZxTriggerTypeEnum {
    /**
     * 开锁类型
     */
    UNLOCK_UNKNOWN(10, "未知开锁", null),
    UNLOCK_FINGER(11, "指纹开锁", null),
    UNLOCK_PWD(12, "密码开锁", null),
    UNLOCK_CARD(13, "刷卡开锁", null),
    UNLOCK_KEY(14, "钥匙开锁", null),
    UNLOCK_BLE(15, "手机开锁", null),
    UNLOCK_REMOTE(16, "遥控开锁", null),
    UNLOCK_TEMP_PWD(17, "临时用户开锁", null),

    /**
     * 报警
     */
    ALARM_LOCK_PICK(20, "撬锁报警", SmsSendTypeEnum.ALARM_LOCK_PICK),
    ALARM_FORCE_UNLOCK(21, "强行开门"),
    ALARM_FINGER_RETRY(22, "指纹尝试开门被冻结", SmsSendTypeEnum.ALARM_UNLOCK_RETRY),
    ALARM_PWD_RETRY(23, "密码尝试开门被冻结", SmsSendTypeEnum.ALARM_UNLOCK_RETRY),
    ALARM_CARD_RETRY(24, "卡尝试开门被冻结", SmsSendTypeEnum.ALARM_UNLOCK_RETRY),
    ALARM_KEY_RETRY(25, "钥匙尝试开门被冻结", SmsSendTypeEnum.ALARM_UNLOCK_RETRY),
    ALARM_REMOTE_RETRY(26, "遥控尝试开门被冻结", SmsSendTypeEnum.ALARM_UNLOCK_RETRY),
    ALARM_HIJACK(27, "劫持报警", SmsSendTypeEnum.ALARM_HIJACK),
    ALARM_BATTERY_LOW(28, "低电量", SmsSendTypeEnum.ALARM_LOW_BATTERY),

    ;
    /**
     * 类型
     */
    private int code;
    /**
     * 名称
     */
    private String name;
    /**
     * 短信类型
     */
    private SmsSendTypeEnum smsSendTypeEnum;

    ZxTriggerTypeEnum(int code, String name) {
        this(code, name, null);
    }

    public static SmsSendTypeEnum getSmsSendTypeByCode(Integer code) {
        if (null != code) {
            for (ZxTriggerTypeEnum triggerTypeEnum : values()) {
                if (triggerTypeEnum.getCode() == code) {
                    return triggerTypeEnum.getSmsSendTypeEnum();
                }
            }
        }
        return null;
    }

}
